<div class="login-wrap">
	<form class="gd-form" id="loginForm">
		<div class="title">Login</div>
		<div class="gd-form-item">
			<input class="gd-input" type="text" name="email" id="loginEmail" placeholder="Email">
		</div>
		<div class="gd-form-item">
			<input class="gd-input" type="password" name="password" id="loginPwd" placeholder="Password">
		</div>
		<div class="gd-form-item" style="margin-top: 0;">
			<div class="extra-row">
				<div class="left">
					<input type="checkbox">
					<span style="cursor: pointer;" onclick="checkedRemember()">Remember Me</span>
				</div>
				<div class="right">
					<a href="javascript:;" onclick="toForget()">Forgot password？</a>
				</div>
			</div>
		</div>
		<div class="gd-form-item">
			<button type="button" class="gd-btn btn-info" onclick="userLogin()">Login</button>
		</div>
	</form>
</div>
<script>
	(() => {
		let mail = localStorage.getItem('gugee_mail')
		if(mail) {
            document.getElementById('loginEmail').value = mail
		}
	})()
	function checkedRemember() {
        let e = document.getElementById('loginForm').querySelector('.extra-row input')
		e.checked = !e.checked
	}
	function userLogin() {
	    let email = document.getElementById('loginEmail').value
		let pwd = document.getElementById('loginPwd').value

		if(!email || !checkEmail(email)) {
		    showToast('please check Email')
			return false
		}
		if(!pwd || pwd.length < 6) {
		    showToast('please check Password')
			return false
		}
        let e = document.getElementById('loginForm').querySelector('.extra-row input')
		if(e.checked) {
		    localStorage.setItem('gugee_mail', email)
		} else {
		    localStorage.removeItem('gugee_mail')
		}
        login(email,pwd)
	}
</script>